/*
 * @Author: c
 * @Date: 2024-03-29 04:05:29
 * @LastEditTime: 2024-03-30 03:40:47
 * @LastEditors: c
 * @Description: 
 * @FilePath: \music-web-backend\src\core\music\search\search.controller.ts
 * https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Body, Controller, Delete, Get, Param, Patch, Post, Query, Req } from '@nestjs/common';
import { SkipAuth } from 'src/core/system/auth/constants';
import { CreateSearchDto } from './dto/create-search.dto';
import { SearchPageDto } from './dto/search.dto';
import { UpdateSearchDto } from './dto/update-search.dto';
import { SearchService } from './search.service';

@Controller('search')
export class SearchController {
  constructor(private readonly searchService: SearchService) { }

  @Post()
  create(@Body() createSearchDto: CreateSearchDto) {
    return this.searchService.create(createSearchDto);
  }

  @SkipAuth()
  @Get('')
  search(@Req() req: any, @Query() search: SearchPageDto) {
    return this.searchService.search(req.user, search);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.searchService.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateSearchDto: UpdateSearchDto) {
    return this.searchService.update(+id, updateSearchDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.searchService.remove(+id);
  }
}
